import com.sun.org.apache.bcel.internal.generic.IFLE;

public class AutoConvert {

    public static void main(String[] args) {
//        演示转换
        int a = 'c'; // 99
        double b = 8;// 8.0
        System.out.println(a);
        System.out.println(b);
        float c = a + 10.223212F;
        System.out.println(c);



        byte d = 12;
        int e = 100;
        double f = 20.11;
        float g = 10.11F;
        short h = 10;

        double nu500 = d+e+f+g+h;
        System.out.println(nu500);


//        强制转换
        double x = ( int )(10*1.5+3.5*20); // 强制转换
        System.out.println(x);//  85.0

//        string基本类型转换
        int n1 = 1;
        float n2 = 2.0F;
        double n3 = 3.0;
        boolean n4 = true;
        String s1 = n1 + "";
        String s2 = n2 + "";
        String s3 = n3 + "";
        String s4 = n4 + "";
        System.out.println(s1 + "  "+ s2 + " "+ s3 + "  " + s4 );//1  2.0 3.0  true

        int x1 = Integer.parseInt("123");
        float f1 = Float.parseFloat("123.0");
        double d1 = Double.parseDouble("123.0");
        long l1 = Long.parseLong("123");
        short ss1 = Short.parseShort("123");
        boolean bb1 = Boolean.parseBoolean("true");
        System.out.println(x1 + "  " + f1 + "  " + d1 + "  " + l1 + "  " + ss1 + " " + bb1);//123  123.0  123.0  123  123 true

        String str = "123";
//        转换成 int类型
//        int n22 = Integer.parseInt("hello");
//        System.out.println(n22); //123
    /*    Exception in thread "main" java.lang.NumberFormatException: For input string: "hello"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:580)
        at java.lang.Integer.parseInt(Integer.java:615)
        at AutoConvert.main(AutoConvert.java:51)
        Disconnected from the target VM, address: '127.0.0.1:17537', transport: 'socket'
        Process finished with exit code 1
     */



    }

}
